package com.julis.activity.main.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.Constant;
import com.baseutils.SpfUtils;
import com.julis.R;
import com.julis.activity.obu_function.OBU_Activate_Activity;
import com.julis.activity.obu_function.OBU_Trade_Activity;
import com.julis.activity.setting.Setting2_Activity;
import com.julis.activity.setting.Setting_Activity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * 设备功能
 */
public class Function_Fragment extends Fragment {
    View view;
    @BindView(R.id.button_check)
    Button buttonJiance;
    @BindView(R.id.button_activate)
    Button buttonJihuo;
    @BindView(R.id.button_trade)
    Button buttonXiaofei;

    @BindView(R.id.layout_jihuo)
    RelativeLayout layoutJihuo;



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (view == null) {
            view = View.inflate(getActivity(), R.layout.fragment_function, null);
            ButterKnife.bind(this, view);

            boolean Menu_Jihuo = (boolean) SpfUtils.get(getActivity(), Constant.Menu_Jihuo, true);
            if (Menu_Jihuo) {
                layoutJihuo.setVisibility(View.VISIBLE);
            } else {
                layoutJihuo.setVisibility(View.GONE);
            }
        }
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null) {
            parent.removeView(view);
        }



        return view;
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();


    }

    @OnClick({R.id.button_activate, R.id.button_trade })
    public void onClick(View view) {
        switch (view.getId()) {
//            case R.id.setting:

//                break;
            case R.id.button_activate:
                startActivity(new Intent(getActivity(), OBU_Activate_Activity.class));
                break;

            case R.id.button_trade:
                startActivity(new Intent(getActivity(), OBU_Trade_Activity.class));

                break;
        }
    }
}
